import unittest
from selenium import webdriver
from Page.Page import Page
from Page.Page2 import Page2
from Page.Page3 import Page3
import time,logging
from ddt import ddt,file_data

@ddt()
class TestA3mall(unittest.TestCase):

    def setUp(self)->None:
        self.driver=webdriver.Firefox()
        self.driver.maximize_window()

    def tearDown(self)->None:
        self.driver.implicitly_wait(12)
        self.driver.quit()
    @file_data(r'D:\gao1\PythonProject7\TestCase\yamla3mall.yaml')
    def test_a3mall_01(self,username,password):
        logging.info('--------start case----------')
        po=Page(self.driver)
        # po.luoji_a3mall_login()
        po.open_url('http://10.59.9.12:7001/')
        po.login()
        print("断言1：", po.dy1())
        self.assertEqual('会员登录', po.dy1())
        po.username(username=username)
        po.password(password=password)
        time.sleep(15)
        po.an()
        time.sleep(5)
        logging.info('--------case end----------')
        # po.sy()
        # po.sousuo()
        # po.san()
        # print("断言2：", po.dy2())
        # self.assertEqual('音乐耳机',po.dy2())
        # po.img()
        # print("断言3：", po.dy3())
        # self.assertIn('耳机', po.dy3())
        # po.sc()
        # time.sleep(4)



    # def test_a3mall_02(self):
    #     try:
    #         po = Page2(self.driver)
    #         # po.luoji_a3mall_add()
    #         po.open_url('http://10.59.9.12:7001/')
    #         time.sleep(5)
    #         po.login()
    #         print("断言1：", po.dy1())
    #         self.assertEqual('会员登录', po.dy1())
    #         po.username()
    #         po.password()
    #         time.sleep(15)
    #         po.an()
    #         po.sy()
    #         po.sousuo()
    #         po.san()
    #         print("断言2：",po.dy2())
    #         self.assertEqual('音乐耳机', po.dy2())
    #         po.img()
    #         print("断言3：", po.dy3())
    #         self.assertIn('耳机', po.dy3())
    #         po.add()
    #         time.sleep(4)
    #     except Exception as e:
    #         t=time.strftime('%Y%m%d%H%M%S',time.localtime())
    #         self.driver.save_screenshot(f'{t}error.png')
    #
    # def test_a3mall_03(self):
    #     po = Page3(self.driver)
    #     # po.luoji_a3mall_buy()
    #     po.open_url('http://10.59.9.12:7001/')
    #     time.sleep(5)
    #     po.login()
    #     print("断言1：", po.dy1())
    #     po.username()
    #     po.password()
    #     time.sleep(15)
    #     po.an()
    #     po.sy()
    #     po.sousuo()
    #     po.san()
    #     print("断言2：", po.dy2())
    #     po.img()
    #     print("断言3：", po.dy3())
    #     self.assertIn('耳机', po.dy3())
    #     po.buy()
    #     po.next()
    #     time.sleep(4)
